// 用户相关的地址池 

const {UsersLogin} = require('../controller/users');
const express = require('express');
const path = require('path');
const router = express.Router(); 
const multer = require('multer');

//创建接收器  

// const upload = multer({dest:'./resource/public'});
// 单key 单文件   

//单key 多文件  
// 配置存储信息 
const upload = multer.diskStorage({
    destination(req,file,cb){
        cb(null,'./resource/public')
    },
    filename(req,file,cb){
        const {ext} = path.parse(file.originalname);

        let newfilename = `${Date.now()}-${Math.random().toString().slice(2)}${ext}`
        cb(null,newfilename)
    }
})
// 创建一个接收器
const upload1 = multer({storage:upload});

// 创建了一个管理地址的对象 

router.post('/avator',upload1.array('avator'),(req,res)=>{
    console.log(123);
    console.log(req.files);
    console.log(req.body)
});
// exports.routers = router;
module.exports = router;
